package com.zone.demo.controller;

import com.zone.demo.service.MyworkService;
import com.zone.demo.util.JsonResult;
import com.zone.demo.util.ResultCode;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description 前端控制器
 *
 * @author nixin
 * @date 2021/7/11 13:32
 */
@RestController
@RequestMapping("/test/myWork")
public class MyworkController {
    private final MyworkService MyworkService;
    private com.zone.demo.service.MyworkService myworkService;

    public MyworkController(MyworkService myworkService) {
        this.MyworkService = myworkService;
    }

    /**
     * Description 加减乘除
     *
     * @param input:    输入算术表达式的字符串
     * @return JsonResult
     * @author nixin
     * @date 2021/7/11 13:49
     */
    @GetMapping("/calculation")
    public JsonResult calculate(String input) {
        String result = this.MyworkService.calculateOperation(input);
        return new JsonResult(ResultCode.SUCCESS, result);
    }

    /**
    * Description
    * @author nixin
    * @date 2021/7/11 21:15
    * @return com.zone.demo.util.JsonResult
    */
    @GetMapping("/getDateFormat")
    public JsonResult getDate() {
        String date = this.myworkService.getDate();
        return new JsonResult(ResultCode.SUCCESS, date);
    }

}


